// pages/me/me.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    topic:{},
    title:"",
    comment:[],
    topicId:"",
    InputValue:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this = this
    this.data.topicId = options.id
    wx.request({
      url: 'http://localhost:8081/exam/getTopic',
      data:{id:options.id},
      success:function(res){
        _this.setData({
          topic:res.data
        })
      }
    })
  },

  submit:function(){
    var _this = this
    wx.request({
      url: 'http://localhost:8081/exam/addComment',
      data:{topicId:_this.data.topicId,comment:_this.data.title},
      success:function(){
        console.log("添加评论成功");
        _this.getComment()
      }
    })
    this.setData({
      InputValue:""
    })
  },

  getComment:function(){
    var _this = this
    wx.request({
      url: 'http://localhost:8081/exam/getComment',
      data:{topicId:_this.data.topicId},
      success:function(res){
        _this.setData({
          comment:res.data
        })
      }
    })
  },

  reply:function(){
    var _this = this
    wx.navigateTo({
      url: '/pages/write/write?flag=2&topicId='+_this.data.topicId,
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */

   onShow:function(){
     this.getComment()
   },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})